package com.edu.app.mapper.linkmappers;

import com.edu.app.bean.core.SysPermission;
import com.edu.app.bean.linkbeans.SysRolePermission;
import com.edu.app.util.AppBaseMapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public interface SysRolePermissionMapper extends AppBaseMapper<SysRolePermission> {
    @Select("SELECT t3.* FROM " +
            "S_ROLE t1 INNER JOIN S_ROLE_PERMISSION t2 on t1.ID = t2.ROLE_ID INNER JOIN S_PERMISSION t3 on t2.PERMISSION_ID = t3.ID " +
            "WHERE t1.id = #{id};")
    List<SysPermission> getPermissionByRoleId(Integer id);

    @Select("SELECT id FROM S_ROLE_PERMISSION WHERE role_id=#{role_id} and permission_id=#{permission_id}")
    Integer getRolePermissionId(@Param("role_id") Integer role_id, @Param("permission_id") Integer permission_id);
}
